package com.aaa.common.config;

import com.google.common.base.Predicates;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.service.VendorExtension;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;


@Configuration
@EnableSwagger2
public class SwaggerConfig {
    @Bean
    public Docket docket(){
        Docket docket=new Docket(DocumentationType.SWAGGER_2)
                //组名
                .groupName("在线教育")
                //api信息
                .apiInfo(getInfo())
                .select()
                //根据请求路径选则
                .paths(Predicates.not(PathSelectors.regex("/error")))

                .build();
        return docket;
    }
    private ApiInfo getInfo() {
        Contact DEFAULT_CONTACT = new Contact("栗萌", "http://www.jd.com", "110@qq .com");
        ApiInfo info=new ApiInfo("在线教育API","在线预约API","2.0","http://www.baidu.com",DEFAULT_CONTACT,"漫动者",
                "http://www.aaa.com",new ArrayList<VendorExtension>());
        return info;
    }
}
